<template>
  <div style="height: 100%;width: 100%;overflow: hidden">
    <el-table v-loading="loading" :data="dataSource" border @row-click="handleRowClick" stripe height="calc(100% - 32px)">
      <el-table-column label="模板名称" prop="excelName" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column label="操作" width="75px" align="center">
        <template slot="header">
          <el-link type="primary" @click="visible = true" icon="el-icon-circle-plus-outline"></el-link>
        </template>
        <template slot-scope="scope">
          <el-link type="success" icon="el-icon-edit" circle @click="editEntity(scope.row, scope.$index)" title="编辑" style="padding-right: 4px"></el-link>
          <el-link type="warning" icon="el-icon-document-copy" circle @click="copyEntity(scope.row, scope.$index)" title="复制" style="padding-right: 4px"></el-link>
          <el-link type="danger" icon="el-icon-delete" circle @click="removeData(scope.row, scope.$index)" title="删除"></el-link>
        </template>
      </el-table-column>
    </el-table>

    <div class="lab-table-page">
      <div style="display: inline-flex">
        <el-pagination
            :disabled="loading"
            :current-page="pageInfo.page"
            :page-sizes="[5, 10, 15, 20, 50, 100]"
            :page-size="pageInfo.pageSize"
            layout="total, prev, pager, next"
            :total="pageInfo.total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
        />
        <el-button-group style="padding: 2px 5px">
          <el-button icon="el-icon-refresh" title="刷新" :disabled="loading" @click="loadSource([])" />
        </el-button-group>
      </div>
    </div>

    <el-dialog :visible="visible" title="模板信息" width="600px" :show-close="false" destroy-on-close>
      <el-form label-position="right" label-width="80px">
        <el-form-item label="模板名称" required>
          <el-input v-model="entityInfo.excelName" placeholder="模板名称,唯一" />
        </el-form-item>
        <el-form-item label="核心线程">
          <el-input-number v-model="entityInfo.corePoolSize" style="width: 100%" controls-position="right"></el-input-number>
        </el-form-item>
        <el-form-item label="存活时间">
          <el-input-number v-model="entityInfo.keepAliveTime" style="width: 100%" controls-position="right"></el-input-number>
        </el-form-item>
        <el-form-item label="队列数量">
          <el-input-number v-model="entityInfo.queueSize" style="width: 100%" controls-position="right"></el-input-number>
        </el-form-item>
        <el-form-item label="模板注释">
          <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="entityInfo.excelComment"></el-input>
        </el-form-item>
        <el-form-item style="width: 100%;text-align: center">
          <el-button icon="el-icon-circle-check" :loading="loading" type="success" @click="saveData(entityInfo)">{{ entityInfo.excelId ? '更新' : (entityInfo.copyId ? '复制' : '保存') }}</el-button>
          <el-button icon="el-icon-circle-close" type="info" @click="visible = false">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
import IdeaTable from "@/mixins/IdeaTable";

/**
 * <p>
 * excel模板表格
 * </p>
 *
 * @author 62688
 * @since  2024/4/27 22:00
 */
export default {
  name: "ExcelTemplateTable",
  mixins: [IdeaTable],
  created() {
    this.queryUrl = '/excelTemplate/queryPage'
    this.saveUrl = '/excelTemplate/save'
    this.removeUrl = '/excelTemplate/delete/'
    this.rowKey = 'excelId'
    this.pageInfo.sorts = [{ field: 'excelId', asc: false }]
    this.initEntity()
    this.loadSource()
  },
  methods: {
    initEntity() {
      this.entityInfo = { corePoolSize: 2, maxPoolSize: 10, keepAliveTime: 60, queueSize: 5 }
    }
  }
}
</script>

<style scoped>

</style>